package com.mall507.fivepeaks.activity.main;

import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout;
import android.text.Html;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.alibaba.android.arouter.launcher.ARouter;
import com.hzh.frame.comn.callback.HttpCallBack;
import com.hzh.frame.core.HttpFrame.BaseHttp;
import com.hzh.frame.ui.fragment.BaseFM;
import com.hzh.frame.util.StatusBarUtil;
import com.hzh.frame.widget.xtitleview.TitleView;
import com.mall507.comn.model.ProfitAd;
import com.mall507.comn.model.User;
import com.mall507.comn.tools.UserTools;
import com.mall507.fivepeaks.R;
import com.mall507.fivepeaks.widget.imageview.CircleImageView;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * @author
 * @version 1.0
 * @date 2019/9/19
 */
public class MainTownShipJieShao1FM extends BaseFM {

    private View mBaseView;

    public static MainTownShipJieShao1FM newInstance(int type,String nid) {
        MainTownShipJieShao1FM myFragment = new MainTownShipJieShao1FM();
        Bundle bundle = new Bundle();
        bundle.putInt("type", type);
        bundle.putString("nid", nid);
        myFragment.setArguments(bundle);
        return myFragment;
    }

    @Override
    public boolean setTitleIsShow() {
        return false;
    }

    @Override
    protected void onCreateBase() {
        mBaseView = setContentView(R.layout.fm_main_township_jieshao);
        getJieShao();
    }
    
    private void getJieShao(){
        JSONObject params = new JSONObject();
        try {
            params.put("id", getArguments().getString("nid"));
        } catch (JSONException e) {
            e.printStackTrace();
        }
        BaseHttp.getInstance().query("Township/getTownshipOne", params, new HttpCallBack() {
            @Override
            public void onSuccess(JSONObject response) {
                JSONObject data = response.optJSONObject("data");

                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                    ((TextView)mBaseView.findViewById(R.id.desc)).setText(String.valueOf(Html.fromHtml(data.optString("township_desc"),Html.FROM_HTML_MODE_COMPACT))); //景点介绍
                }else {
                    ((TextView)mBaseView.findViewById(R.id.desc)).setText(String.valueOf(Html.fromHtml(data.optString("township_desc")))); //景点介绍
                }
            }
        });
    }
}
